package com.treasure.service.collocate.controller;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.collocate.service.GainStatisticsService;
import com.treasure.service.dto.RankingListDto;
import com.treasure.service.enums.CodeEnum;
import com.treasure.service.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
* @Description:    排行榜统计
* @Author:         panxinwen
* @CreateDate:     2018/12/9 12:17
* @Version:        1.0
*/
@Api(value = "排行榜统计",description = "排行榜统计")
@RestController
@RequestMapping("/gainStatistics/v1")
public class GainStatisticsController {

    @Autowired
    private GainStatisticsService gainStatisticsService;

    @ApiOperation(value = "获取排行榜", notes = "获取排行榜")
    @PostMapping("/getRankingList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "timeType", value = "统计单位(0-全部 1-天，2-周 3-月 4-季 5-年)", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "dataType", value = "统计类型(1-总利润，2-自己办卡利润 3-邀请办卡利润 4-团队分成)", required = false, dataType = "int", paramType = "query")
    })
    @LogInfo(log = "获取排行榜",isPrint = true)
    public ResponseEntity getRankingList(@RequestParam(value = "timeType",required = false,defaultValue = "2") Integer timeType,
                                         @RequestParam(value = "dataType",required = false ,defaultValue = "1") Integer dataType){

        Map map = gainStatisticsService.getRankingList(timeType,dataType);

        return ResponseEntity.ok( new ResponseResult(CodeEnum.SUCCESS,map));

    }

}
